function showMFooter(){
	var jsondata=jQuery("#material").datagrid("getData");
	var total = 0;
//	alert(jsondata);
//alert(jsondata.rows.length);
	for(var i=0;i<jsondata.rows.length;i++){
		total += parseFloat(jsondata.rows[i].price)*parseFloat(jsondata.rows[i].num);
	}
	total = Math.round(total*Math.pow(10,2))/Math.pow(10,2);
	jQuery('#material').datagrid('reloadFooter',[
	                              	{
	                              		price:'合计:',
	                              		num: total 
	                              	 }
	                              ]);
}
function showFFooter(){
	var jsondata=jQuery("#fb_detail").datagrid("getData");
	var total = 0;
	for(var i=0;i<jsondata.rows.length;i++){
		total += parseFloat(jsondata.rows[i].budget);
	}
	total = Math.round(total*Math.pow(10,2))/Math.pow(10,2);
	jQuery('#fb_detail').datagrid('reloadFooter',[
	                                             {
	                                            	 fb_item_name:'合计:',
	                                            	 budget: total 
	                                             }
	                                             ]);
}
function uploadSuccessOver(file, serverData) {
	try {
		var progress = new FileProgress(file,
				this.customSettings.progressTarget);
		progress.toggleCancel(false);
		var json = null;
		json = serverData.evalJSON();
		if (json.rtState == "1") {
			progress.setError();
			progress.setStatus("上传失败");
		} else {
			if ($('attachmentId').value != null
					&& $('attachmentId').value != "") {
				$('attachmentId').value += ',' + json.rtData.attachmentId;
			} else {
				$('attachmentId').value = json.rtData.attachmentId;
			}
			if ($('attachmentName').value != null
					&& $('attachmentName').value != "") {
				$('attachmentName').value += '*' + json.rtData.attachmentName;
			} else {
				$('attachmentName').value = json.rtData.attachmentName;
			}
		}
	} catch (ex) {
		this.debug(ex);
	}
}

function queueCompleteOver() {
	var attachmentIds = $("attachmentId").value;
	var attachmentNames = $("attachmentName").value;
	if (attachmentIds) {
		jQuery('#attaTr').show();
		jQuery('#fsUploadArea').hide();
		if(isShow == 1){
			attachMenuUtil("showAtt", null, null, attachmentNames, attachmentIds,true, 'attach');
		}else{
			attachMenuUtil("showAtt", null, null, attachmentNames, attachmentIds,false, 'attach');
		}
	}
}

function deleteAttachment(attachmentId, attachmentName) {
	var attrIds = $("attachmentId").value;
	var attrNames = $("attachmentName").value;
	var attrIdArrays = attrIds.split(",");
	var attrNameArrays = attrNames.split("*");
	var idArray = new Array();
	var nameArray = new Array();

	for ( var i = 0; i < attrIdArrays.length; i++) {
		if (attrIdArrays[i] != attachmentId) {
			idArray.push(attrIdArrays[i]);
			nameArray.push(attrNameArrays[i]);
		}
	}
	$("attachmentId").value = idArray.join(",");
	$("attachmentName").value = nameArray.join("*");
	if ($("attachmentId").value == "") {
		jQuery('#attaTr').hide();
	}
}

function doSearch() {
	var dept_id = jQuery('#p_dept_id').combotree('getValue');
	var searchValue = jQuery('#searchValue').val();
	jQuery('#gd_admin_id').combogrid("grid").datagrid('load', {
		searchValue : searchValue,
		dept_id:dept_id
	});
}
function doSearch1() {
	var searchValue = jQuery('#searchValue1').val();
	var type_id = jQuery('#type_id').val();
	jQuery('#gd_worker_id').combogrid("grid").datagrid('load', {
		searchValue : searchValue,
		type_id : type_id
	});
}
function domSearch() {
	var mSearchValue = jQuery('#mSearchValue').val();
	var material_type_id = jQuery('#material_type_id').combotree('getValue');
	jQuery(combogridTarget).combogrid('grid').datagrid('load', {
		searchValue : mSearchValue,
		material_type_id : material_type_id
	});
}

function deleteFBRow() {
	jQuery('#fb_detail').datagrid('acceptChanges');
	fb_lastIndex = -1;
	var rows = jQuery('#fb_detail').datagrid('getSelections');
	if (rows.length > 0) {
		for ( var i = 0; i < rows.length; i++) {
			var row = rows[i];
			var index = jQuery('#fb_detail').datagrid('getRowIndex', row);
			jQuery('#fb_detail').datagrid('deleteRow', index);
		}
	}
	var data = jQuery('#fb_detail').datagrid('getData');
	jQuery('#fb_detail').datagrid('loadData', data);
}
function deleteMRow() {
	jQuery('#material').datagrid('acceptChanges');
	m_lastIndex = -1;
	var rows = jQuery('#material').datagrid('getSelections');
	if (rows.length > 0) {
		for ( var i = 0; i < rows.length; i++) {
			var row = rows[i];
			var index = jQuery('#material').datagrid('getRowIndex', row);
			jQuery('#material').datagrid('deleteRow', index);
		}
	}
	var data = jQuery('#material').datagrid('getData');
	jQuery('#material').datagrid('loadData', data);
}
function addFBRow() {
	jQuery('#fb_detail').datagrid('endEdit', fb_lastIndex);
	jQuery('#fb_detail').datagrid('appendRow', {
		fb_item_name : '',
		budget : '',
		budget_remark : ''
	});
	var data = jQuery('#fb_detail').datagrid('getData');
	jQuery('#fb_detail').datagrid('loadData', data);
	fb_lastIndex = jQuery('#fb_detail').datagrid('getRows').length - 1;
	jQuery('#fb_detail').datagrid('selectRow', fb_lastIndex);
	jQuery('#fb_detail').datagrid('beginEdit', fb_lastIndex);
}
function addMRow() {
	jQuery('#material').datagrid('endEdit', m_lastIndex);
	jQuery('#material').datagrid('appendRow', {});
	var data = jQuery('#material').datagrid('getData');
	jQuery('#material').datagrid('loadData', data);
	m_lastIndex = jQuery('#material').datagrid('getRows').length - 1;
	jQuery('#material').datagrid('selectRow', m_lastIndex);
	jQuery('#material').datagrid('beginEdit', m_lastIndex);
}

function doSearchc() {
	var searchValue = jQuery('#searchValuec').val();
	var type_id = jQuery('#customer_type_id').combotree('getValue');
	jQuery('#customer_id').combogrid("grid").datagrid('load', {
		searchValue : searchValue,
		type_id : type_id
	});
}

function rtCallBackXmSet(xm_id, xm_code, xm_name) {
	jQuery("#xm_id").val(xm_id);
	jQuery("#xm_code").val(xm_code);
	jQuery("#xm_name").val(xm_name);
}